package net.bolue.web.mvc;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bolue.console.model.InsertModel;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.model.InsResModel;
import net.bolue.sysmng.tblbean.InsRes;
import net.bolue.web.report.RepConstants;
import net.bolue.web.util.RequestUtil;

/**
 * 
 * 新增功能
 * @author Administrator
 *
 */
public class InsertAction extends AbstractAction{

	@Override
	public ActionResult perform(HttpServletRequest request, HttpServletResponse response)throws BolueException {
		String subSys = RequestUtil.getParamValue(request, RepConstants.REP_SUBSYS_KEY);
		String insertID = RequestUtil.getParamValue(request, RepConstants.REP_INSERTID_KEY);
		if(subSys==null || subSys.trim().length()==0 || insertID==null || insertID.trim().length()==0){
			throw new BolueException(1, "新增URL中必须提供subSys及insertID参数值!");
		}
		
		InsResModel insResModel = new InsResModel(request);
		InsRes insRes = insResModel.getInsRes(subSys, insertID);
		if(insRes==null){
			throw new BolueException(10, "没有找到subSys="+subSys+",insertID="+insertID+"的新增资源！");
		}
		
		InsertModel insertModel = new InsertModel(request,insRes);
		return insertModel.insert();
	}
	
}
